package com.wz.common.controller;


import com.wz.common.bean.ResultBean;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLException;

/**
 * <p>Project: wz_api - GlobalExceptionController
 * <p>Powered by pisces On 2022-01-16 20:57:02
 * <P>Created by IntelliJ IDEA
 *
 * @author ww606851@163.com
 * @version 1.0
 * @description:
 * @since 8
 */

@ControllerAdvice(basePackages = "com.wz")
@ResponseBody
public class GlobalExceptionController extends BaseController {

    @ExceptionHandler(NullPointerException.class)
    public ResultBean processNullPointerException(NullPointerException e) {
        String msg = e.toString();
        e.printStackTrace();
        return fail(msg);
    }

    @ExceptionHandler(SQLException.class)
    public ResultBean processSQLException(SQLException e) {
        String msg = e.toString();
        e.printStackTrace();
        return fail(msg);
    }
}
